import 'package:flutter/material.dart';
import 'package:flutter_09_game/config/app_color.dart';
import 'package:flutter_09_game/generated/assets.dart';
import 'package:flutter_09_game/widgets/image/auto_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class CommonNormalSheet extends StatelessWidget {
  const CommonNormalSheet({
    super.key,
    this.title,
    required this.child,
  });

  static String name = 'CommonNormalSheet';
  final String? title;
  final Widget child;

  Future show() async {
    return await Get.bottomSheet(this,
        isScrollControlled: true,
        barrierColor: Colors.black.withOpacity(0.50),
        settings: RouteSettings(name: name));
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.end,
      mainAxisSize: MainAxisSize.min,
      children: [
        Container(
          padding: EdgeInsets.only(bottom: ScreenUtil().bottomBarHeight + 16.w),

          //     .copyWith(bottom: ScreenUtil().bottomBarHeight + 16.w),
          decoration: BoxDecoration(
              color: AppColor.pageBgColor,
              border: const Border(
                  top: BorderSide(color: AppColor.primary, width: 1)),
              borderRadius: BorderRadius.only(
                  topRight: Radius.circular(16.w),
                  topLeft: Radius.circular(16.w))),
          child: Column(
            children: [
              Container(
                // height: 46.w,
                padding: EdgeInsets.all(8.w),
                decoration: BoxDecoration(
                  gradient: LinearGradient(colors: [
                    AppColor.primary.withOpacity(0.15),
                    AppColor.navBgColor.withOpacity(0)
                  ], begin: Alignment.topCenter, end: Alignment.bottomCenter),
                ),
                child: Align(
                  alignment: Alignment.centerRight,
                  child: GestureDetector(
                    onTap: () {
                      Get.back();
                    },
                    child: AutoImage(
                      Assets.commonCancelBtn,
                      width: 32.w,
                    ),
                  ),
                ),
              ),
              12.verticalSpaceFromWidth,
              Visibility(
                  visible: (title ?? "").isNotEmpty,
                  child: Text(
                    title ?? "",
                    textAlign: TextAlign.center,
                    style: TextStyle(
                        color: AppColor.textPrimary.withOpacity(0.94),
                        fontSize: 16.sp,
                        fontWeight: FontWeight.w600),
                  ).marginOnly(bottom: 24.w)),
              child
            ],
          ),
        )
      ],
    );
  }
}
